package com.daxt.controller.infomanager;

import java.util.ArrayList;
import java.util.List;

import com.daxt.common.annotations.LoginAuth;
import com.daxt.common.annotations.LoginUser;
import com.daxt.mapper.archives.ArchivesIdentRecordMapper;
import com.daxt.mapper.sys.DicMapper;
import com.daxt.model.dic.BehaveLogType;
import com.daxt.model.dic.DicDocPattern;
import com.daxt.model.dic.DicDocState;
import com.daxt.model.service.archives.result.ArchivesCount;
import com.daxt.model.service.archives.vo.ArchivesBehaveLog;
import com.daxt.model.service.archives.vo.ArchivesIdentRecord;
import com.daxt.model.service.base.vo.Dic;
import com.daxt.service.ArchivesBehaveLogService;
import com.daxt.service.ArchivesService;
import com.daxt.service.DocService;
import com.daxt.utils.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daxt.base.common.util.RedisUtil;
import com.daxt.base.common.util.UserInfoUtil;
import com.daxt.common.result.PageInfo;
import com.daxt.common.result.PageUtil;
import com.daxt.common.result.Result;
import com.daxt.common.result.ResultCode;
import com.daxt.common.result.ResultUtil;
import com.daxt.mapper.archives.ArchivesDocMapper;
import com.daxt.model.service.archives.vo.ArchivesDoc;
import com.daxt.model.service.base.result.UserInfo;
import com.daxt.utils.LocalDateTimeUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "待鉴定")
@RestController
@RequestMapping("/infoManager")
public class AppraisalController {

	@Autowired
	private ArchivesDocMapper archivesDocMapper;
	@Autowired
	private DocService docService;
	@Autowired
	private ArchivesService archivesService;
//	@Autowired
//	private ArchivesDestroyRecordMapper archivesDestroyRecordMapper;
	@Autowired
	private ArchivesIdentRecordMapper archivesIdentRecordMapper;
	@Autowired
	private ArchivesBehaveLogService archivesBehaveLogService;
	@Autowired
	private RedisUtil redisUtil;
	@Autowired
	private UserInfoUtil userInfoUtil;
	@Autowired
	private DicMapper dicMapper;

//	@ApiOperation(value = "撤销鉴定", notes = "")
//	@PostMapping("/appraisal/reject")
//	@Transactional(rollbackFor = Exception.class)
//	public Result<String> list(@RequestBody SetStateParam setStateParam) {
//		try {
//			List<String> ids = setStateParam.getIds();
//			for (String string : ids) {
//				if ("doc".equals(setStateParam.getType())) {
//					ArchivesDoc entity = new ArchivesDoc();
//					entity.setId(Long.parseLong(string));
//					entity.setState("2");
//					archivesDocMapper.updateById(entity);
//					QueryWrapper<ArchivesDestroyRecord> wrapperDel = new QueryWrapper<ArchivesDestroyRecord>();
//					wrapperDel.eq("fileId", string);
//					wrapperDel.eq("state", "0");
//					archivesDestroyRecordMapper.delete(wrapperDel);
//				} else if ("dossier".equals(setStateParam.getType())) {
//					ArchivesDoc entity = new ArchivesDoc();
//					entity.setId(Long.parseLong(string));
//					entity.setState("2");
//					int update = archivesDocMapper.updateById(entity);
//					if (update <= 0) {
//						throw new Exception();
//					}
//					QueryWrapper<ArchivesDestroyRecord> wrapperDel = new QueryWrapper<ArchivesDestroyRecord>();
//					wrapperDel.eq("fileId", string);
//					wrapperDel.eq("state", "0");
//					archivesDestroyRecordMapper.delete(wrapperDel);
//					UpdateWrapper<ArchivesDoc> updateWrapper = new UpdateWrapper<ArchivesDoc>();
//					updateWrapper.in("dossierId", string);
//					ArchivesDoc docEntity = new ArchivesDoc();
//					docEntity.setState("2");
//					archivesDocMapper.update(docEntity, updateWrapper);
//					QueryWrapper<ArchivesDoc> queryWrapperList = new QueryWrapper<ArchivesDoc>();
//					queryWrapperList.in("dossierId", ids);
//					List<ArchivesDoc> selectList = archivesDocMapper.selectList(queryWrapperList);
//					if (selectList != null && selectList.size() > 0) {
//						List<Long> delIds = new ArrayList<Long>();
//						for (ArchivesDoc tempDoc : selectList) {
//							delIds.add(tempDoc.getId());
//						}
//						QueryWrapper<ArchivesDestroyRecord> wrapperDel1 = new QueryWrapper<ArchivesDestroyRecord>();
//						wrapperDel1.in("fileId", delIds);
//						wrapperDel1.eq("state", "0");
//						archivesDestroyRecordMapper.delete(wrapperDel1);
//					}
//
//				}
//			}
//			return ResultUtil.data(ResultCode.RESULT_SUCCESS.getCode(), "", "");
//		} catch (Exception e) {
//			e.printStackTrace();
//			return ResultUtil.data(ResultCode.RESULT_ERROR.getCode(), "", "");
//		}
//	}

//	@ApiOperation(value = "档案鉴定", notes = "")
//	@PostMapping("/appraisal/ident")
//	public Result<String> list(@RequestBody List<Long> ids, HttpServletRequest request) throws Exception {
//		try {
//		UserInfo userInfo = userInfoUtil.getLoginInfo(UserInfo.class, redisUtil, request);
//		if (ids != null && ids.size() > 0) {
//			ArchivesDoc selectById = archivesDocMapper.selectById(ids.get(0));
//			if ("doc".equals(selectById.getFileType()) && selectById.getDossierId().intValue() != 0) {
//				for (Long id : ids) {
//					QueryWrapper<ArchivesDestroyRecord> queryWrapper = new QueryWrapper<ArchivesDestroyRecord>();
//					queryWrapper.eq("state", "0");
//					queryWrapper.eq("fileId", id);
//					List<ArchivesDestroyRecord> selectList = archivesDestroyRecordMapper.selectList(queryWrapper);
//					ArchivesDoc entity1 = new ArchivesDoc();
//					entity1.setId(id);
//					entity1.setState("2");
//					if ("销毁".equals(selectList.get(0).getIdentType())) {
//						archivesDocMapper.deleteById(id);
//					} else {
//						// "划控".equals((selectList==null||selectList.size()==0)?"":selectList.get(0).getIdentType())
//						if (!"销毁".equals(selectList.get(0).getIdentType())) {
//							entity1.setOpenState("控制".equals((selectList == null || selectList.size() == 0) ? ""
//									: selectList.get(0).getProlongTime()) ? "2" : "1");
//						}
//						archivesDocMapper.updateById(entity1);
//					}
//					QueryWrapper<ArchivesDestroyRecord> updateWrapper = new QueryWrapper<ArchivesDestroyRecord>();
//					updateWrapper.eq("state", "0");
//					updateWrapper.eq("fileId", id);
//					ArchivesDestroyRecord entity2 = new ArchivesDestroyRecord();
//					entity2.setState("1");
//					entity2.setReviewBy(userInfo.getRealName());
//					archivesDestroyRecordMapper.update(entity2, updateWrapper);
//				}
//
//			} else {
//
//				for (Long id : ids) {
//					QueryWrapper<ArchivesDestroyRecord> queryWrapper = new QueryWrapper<ArchivesDestroyRecord>();
//					queryWrapper.eq("state", "0");
//					queryWrapper.eq("fileId", id);
//					List<ArchivesDestroyRecord> selectList = archivesDestroyRecordMapper.selectList(queryWrapper);
//					ArchivesDoc entity1 = new ArchivesDoc();
//					entity1.setId(id);
//					entity1.setState("2");
//					if ("销毁".equals(selectList.get(0).getIdentType())) {
//						archivesDocMapper.deleteById(id);
//					} else {
//						// "划控".equals((selectList==null||selectList.size()==0)?"":selectList.get(0).getIdentType())
//						if (!"销毁".equals(selectList.get(0).getIdentType())) {
//							entity1.setOpenState("控制".equals((selectList == null || selectList.size() == 0) ? ""
//									: selectList.get(0).getProlongTime()) ? "2" : "1");
//						}
//						archivesDocMapper.updateById(entity1);
//					}
//
//					QueryWrapper<ArchivesDestroyRecord> updateWrapper = new QueryWrapper<ArchivesDestroyRecord>();
//					updateWrapper.eq("state", "0");
//					updateWrapper.eq("fileId", id);
//					ArchivesDestroyRecord entity2 = new ArchivesDestroyRecord();
//					entity2.setState("1");
//					entity2.setReviewBy(userInfo.getRealName());
//					archivesDestroyRecordMapper.update(entity2, updateWrapper);
//
//					QueryWrapper<ArchivesDoc> queryWrapperList = new QueryWrapper<ArchivesDoc>();
//					queryWrapperList.eq("dossierId", id);
//					queryWrapperList.eq("state", "3");
//					List<ArchivesDoc> selectListDoc = archivesDocMapper.selectList(queryWrapperList);
//					for (ArchivesDoc archivesDocTemp : selectListDoc) {
//
//						QueryWrapper<ArchivesDestroyRecord> queryWrapperDoc = new QueryWrapper<ArchivesDestroyRecord>();
//						queryWrapperDoc.eq("state", "0");
//						queryWrapperDoc.eq("fileId", archivesDocTemp.getId());
//						List<ArchivesDestroyRecord> selectListDocT = archivesDestroyRecordMapper
//								.selectList(queryWrapperDoc);
//						ArchivesDoc entityDoc = new ArchivesDoc();
//						entityDoc.setId(archivesDocTemp.getId());
//						entityDoc.setState("2");
//						if ("销毁".equals(selectList.get(0).getIdentType())) {
//							archivesDocMapper.deleteById(entityDoc.getId());
//						} else {
//							// "划控".equals((selectList==null||selectList.size()==0)?"":selectList.get(0).getIdentType())
//							entityDoc.setOpenState(
//									"控制".equals((selectListDocT == null || selectListDocT.size() == 0) ? ""
//											: selectListDocT.get(0).getProlongTime()) ? "2" : "1");
//							archivesDocMapper.updateById(entityDoc);
//						}
//
//						QueryWrapper<ArchivesDestroyRecord> updateWrapperDoc = new QueryWrapper<ArchivesDestroyRecord>();
//						updateWrapperDoc.eq("state", "0");
//						updateWrapperDoc.eq("fileId", archivesDocTemp.getId());
//						ArchivesDestroyRecord entityDoc2 = new ArchivesDestroyRecord();
//						entityDoc2.setState("1");
//						entityDoc2.setReviewBy(userInfo.getRealName());
//						archivesDestroyRecordMapper.update(entityDoc2, updateWrapperDoc);
//					}
//
//				}
//
//			}
//
//			return ResultUtil.data(ResultCode.RESULT_SUCCESS.getCode(), "", "");
//		} else {
//			return ResultUtil.data(ResultCode.RESULT_ERROR.getCode(), "", "");
//		}
//		}catch (Exception e) {
//			e.printStackTrace();
//			return ResultUtil.data(ResultCode.RESULT_ERROR.getCode(), "", null);
//		}
//	}

	@LoginAuth()
	@ApiOperation(value = "鉴定", notes = "")
	@PostMapping("/appraisal/ident")
	@Transactional(rollbackFor = Exception.class)
	public Result<String> ident(@ApiIgnore @LoginUser UserInfo loginUser,
			@ApiParam("文档模式，0件，1卷") @RequestParam(value = "model", required = true) String model,
			@ApiParam("鉴定方式：1-延期、2-销毁") @RequestParam(value = "identType", required = true) String identType,
			@ApiParam("保管期限（字典）") @RequestParam(value = "storagePeriod", required = false) String storagePeriod,
			@ApiParam("密集（字典）") @RequestParam(value = "secret", required = false) String secret,
			@RequestBody List<String> ids,
			HttpServletRequest request) {

			ids.forEach((String id)->{

				//总页数
				String pages = "0";
				//总件数
				String docNum = "1";
				List<ArchivesDoc> docList = new ArrayList<>();
				ArchivesDoc bean = archivesDocMapper.selectById(id);
				pages = bean.getPages();
				docList.add(bean);

				if (DicDocPattern.PATTERN_1.getKey().equals(model)){
					QueryWrapper queryWrapper = new QueryWrapper();
					queryWrapper.eq("dossierId",id);
					List<ArchivesDoc> dossierUnderList  = archivesDocMapper.selectList(queryWrapper);
					if(BaseUtil.listIsNotNullElement(dossierUnderList)){

						docList.addAll(dossierUnderList);
						docNum = dossierUnderList.size() +"";

						ArchivesCount ac = archivesDocMapper.countVolumes(Long.parseLong(id));
						pages = ac.getTotalPages() + "";
					}


				}


				String finalPages = pages;
				String finalDocNum = docNum;
				docList.forEach((ArchivesDoc doc)->{
					ArchivesIdentRecord air = new ArchivesIdentRecord();
					air.setDocId(doc.getId());
					air.setArchivalNum(doc.getArchivalNum());
					air.setIdentType(identType);
					air.setFondsId(doc.getFondsId());
					air.setModel(model);
					air.setCreateBy(loginUser.getRealName());
					air.setCreateTime(LocalDateTimeUtil.getNowTimeYMD());
					air.setTotalPages(finalPages);
					air.setTotalDocNum(finalDocNum);


					if ("2".equals(identType)) {
						//删除数据
						archivesDocMapper.deleteById(id);
					}else if ("1".equals(identType)) {//延期
						air.setProlongTime(storagePeriod);
						air.setOriginalPeriod(doc.getStoragePeriod());

						//修改数据
						doc.setStoragePeriod(storagePeriod);
						doc.setSecret(secret);
						doc.setState(DicDocState.archive.getKey());
						archivesDocMapper.updateById(doc);

					}

					//鉴定记录
					archivesIdentRecordMapper.insert(air);
				});


			});
			if ("2".equals(identType)) {
				archivesBehaveLogService.saveArchivesBehaveLog(new ArchivesBehaveLog(BaseUtil.listToString(ids), BehaveLogType.DESTROY.getKey(),BehaveLogType.DESTROY.getValue(),null),loginUser ,request);
			}else if ("1".equals(identType)) {//延期
				Dic dic = dicMapper.selectOne(new QueryWrapper<Dic>().eq("dicType","storagePeriod").eq("dicCode",storagePeriod));
				String description="保管期限调整为："+dic.getDicValue();
				archivesBehaveLogService.saveArchivesBehaveLog(new ArchivesBehaveLog(BaseUtil.listToString(ids),BehaveLogType.POSTPONE.getKey(),BehaveLogType.POSTPONE.getValue(),description),loginUser ,request);
			}
			return ResultUtil.success();
//
	}
//	@ApiOperation(value = "销毁", notes = "")
//	@PostMapping("/appraisal/destroy")
//	public Result<String> destroy(@RequestBody ArchivesDestroyRecord archivesDestroyRecord,
//			HttpServletRequest request) {
//		try {
//		UserInfo userInfo = userInfoUtil.getLoginInfo(UserInfo.class, redisUtil, request);
//		archivesDestroyRecord.setCreateBy(userInfo.getRealName());
//		archivesDestroyRecord.setCreateTime(LocalDateTimeUtil.getNowTimeYMD());
//
//		int insert = archivesDestroyRecordMapper.insert(archivesDestroyRecord);
//		if (insert > 0) {
//			if ("0".equals(archivesDestroyRecord.getModel())) {
//				if ("销毁".equals(archivesDestroyRecord.getIdentType())) {
//					archivesDocMapper.deleteById(archivesDestroyRecord.getFileId());
//				} else if ("鉴定".equals(archivesDestroyRecord.getIdentType())) {
//					ArchivesDoc entity = new ArchivesDoc();
//					entity.setState("2");
//					archivesDocMapper.updateById(entity);
//				}
//			} else if ("1".equals(archivesDestroyRecord.getModel())) {
//				if ("销毁".equals(archivesDestroyRecord.getIdentType())) {
//					archivesDocMapper.deleteById(archivesDestroyRecord.getFileId());
//					QueryWrapper<ArchivesDoc> wrapper = new QueryWrapper<ArchivesDoc>();
//					wrapper.eq("dossierId", archivesDestroyRecord.getFileId());
//					archivesDocMapper.delete(wrapper);
//				} else if ("鉴定".equals(archivesDestroyRecord.getIdentType())) {
//					ArchivesDoc entity = new ArchivesDoc();
//					entity.setState("2");
//					archivesDocMapper.updateById(entity);
//					QueryWrapper<ArchivesDoc> updateWrapper = new QueryWrapper<ArchivesDoc>();
//					updateWrapper.eq("dossierId", archivesDestroyRecord.getFileId());
//					archivesDocMapper.update(entity, updateWrapper);
//				}
//			}
//		}
//		return ResultUtil.data(ResultCode.RESULT_SUCCESS.getCode(), "", "");
//		}catch (Exception e) {
//			e.printStackTrace();
//			return ResultUtil.data(ResultCode.RESULT_ERROR.getCode(), "", null);
//		}
//	}

//	@ApiOperation(value = "销毁列表", notes = "")
//	@GetMapping("/appraisal/destroy")
//	public Result<PageInfo<ArchivesDestroyRecord>> destroyList(
//			@ApiParam("") @RequestParam(value = "pageNum", required = false) Integer pageNum,
//			@ApiParam("") @RequestParam(value = "pageSize", required = false) Integer pageSize,
//			@ApiParam("题名") @RequestParam(value = "title", required = false) String title,
//			@ApiParam("鉴定开始时间") @RequestParam(value = "startTime", required = false) String startTime,
//			@ApiParam("鉴定结束时间") @RequestParam(value = "endTime", required = false) String endTime,
//			@ApiParam("鉴定类型") @RequestParam(value = "identType", required = false) String identType,
//			@ApiParam("分类号") @RequestParam(value = "classNum", required = false) String classNum,
//			@ApiParam("档案类型") @RequestParam(value = "typeNmu", required = false) String typeNmu,
//			@ApiParam("全宗ID") @RequestParam(value = "fondsId", required = false) String fondsId) {
//		Page<ArchivesDestroyRecord> page = new Page<>(pageNum == null ? 0 : pageNum, pageSize == null ? 10 : pageSize);
//		QueryWrapper<ArchivesDestroyRecord> queryWrapper = new QueryWrapper<>();
//		if (!StringUtils.isEmpty(title)) {
//			queryWrapper.like("title", "%" + title + "%");
//		}
//		if (!StringUtils.isEmpty(identType)) {
//			queryWrapper.eq("identType", identType);
//		}
//		if (!StringUtils.isEmpty(classNum)) {
//			queryWrapper.eq("classNum", classNum);
//		}
//		if (!StringUtils.isEmpty(typeNmu)) {
//			queryWrapper.eq("typeNmu", typeNmu);
//		}
//		if (!StringUtils.isEmpty(typeNmu)) {
//			queryWrapper.eq("typeNmu", typeNmu);
//		}
//		if (!StringUtils.isEmpty(fondsId)) {
//			queryWrapper.eq("fondsId", fondsId);
//		}
//		if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
//			queryWrapper.between("createTime", startTime, endTime);
//			// queryWrapper.lt("createTime", endTime);
//		}
//		queryWrapper.eq("identType", "销毁");
//		queryWrapper.eq("state", "1");
//		queryWrapper.groupBy("title");
//		//queryWrapper.last(" and prolongTime != '0'");
//		IPage<ArchivesDestroyRecord> info = archivesDestroyRecordMapper.selectPage(page, queryWrapper);
//		PageInfo<ArchivesDestroyRecord> data = PageUtil.data(info.getPages(), info.getCurrent(), info.getTotal(),
//				info.getRecords());
//		return ResultUtil.data(ResultCode.RESULT_SUCCESS.getCode(), "", data);
//	}

//	@ApiOperation(value = "鉴定列表", notes = "")
//	@GetMapping("/appraisal/ident")
//	public Result<PageInfo<ArchivesDestroyRecord>> identList(
//			@ApiParam("") @RequestParam(value = "pageNum", required = false) Integer pageNum,
//			@ApiParam("") @RequestParam(value = "pageSize", required = false) Integer pageSize,
//			@ApiParam("题名") @RequestParam(value = "title", required = false) String title,
//			@ApiParam("鉴定开始时间") @RequestParam(value = "startTime", required = false) String startTime,
//			@ApiParam("鉴定结束时间") @RequestParam(value = "endTime", required = false) String endTime,
//			@ApiParam("鉴定类型") @RequestParam(value = "identType", required = false) String identType,
//			@ApiParam("分类号") @RequestParam(value = "classNum", required = false) String classNum,
//			@ApiParam("档案类型") @RequestParam(value = "typeNmu", required = false) String typeNmu,
//			@ApiParam("全宗ID") @RequestParam(value = "fondsId", required = false) String fondsId) {
//		Page<ArchivesDestroyRecord> page = new Page<>(pageNum == null ? 0 : pageNum, pageSize == null ? 10 : pageSize);
//		QueryWrapper<ArchivesDestroyRecord> queryWrapper = new QueryWrapper<>();
//		if (!StringUtils.isEmpty(title)) {
//			queryWrapper.like("title", "%" + title + "%");
//		}
//		/*
//		 * identType="划控"; if(!StringUtils.isEmpty(identType)) {
//		 * queryWrapper.eq("identType", identType); }
//		 */
//		if (!StringUtils.isEmpty(classNum)) {
//			queryWrapper.eq("classNum", classNum);
//		}
//		if (!StringUtils.isEmpty(typeNmu)) {
//			queryWrapper.eq("typeNmu", typeNmu);
//		}
//		if (!StringUtils.isEmpty(typeNmu)) {
//			queryWrapper.eq("typeNmu", typeNmu);
//		}
//		if (!StringUtils.isEmpty(fondsId)) {
//			queryWrapper.eq("fondsId", fondsId);
//		}
//		if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
//			queryWrapper.between("createTime", startTime, endTime);
//			// queryWrapper.lt("createTime", endTime);
//		}
//		queryWrapper.eq("identType", "划控");
//		queryWrapper.eq("state", "1");
//		queryWrapper.orderByDesc("createTime");
//		IPage<ArchivesDestroyRecord> info = archivesDestroyRecordMapper.selectPage(page, queryWrapper);
//		PageInfo<ArchivesDestroyRecord> data = PageUtil.data(info.getPages(), info.getCurrent(), info.getTotal(),
//				info.getRecords());
//		return ResultUtil.data(ResultCode.RESULT_SUCCESS.getCode(), "", data);
//	}



	@ApiOperation(value = "鉴定列表", notes = "")
	@GetMapping("/appraisal/ident")
	public Result<PageInfo<ArchivesIdentRecord>> identList(
			@ApiParam("") @RequestParam(value = "pageNum", required = false) Integer pageNum,
			@ApiParam("") @RequestParam(value = "pageSize", required = false) Integer pageSize,
			@ApiParam("题名") @RequestParam(value = "title", required = false) String title,
			@ApiParam("鉴定开始时间") @RequestParam(value = "startTime", required = false) String startTime,
			@ApiParam("鉴定结束时间") @RequestParam(value = "endTime", required = false) String endTime,
			@ApiParam("鉴定方式：1-延期、2-销毁") @RequestParam(value = "identType", required = true) String identType,
			@ApiParam("分类ID") @RequestParam(value = "classId", required = false) String classId,
			@ApiParam("档案类型") @RequestParam(value = "typeId", required = false) String typeId,
			@ApiParam("全宗ID") @RequestParam(value = "fondsId", required = false) String fondsId,
			HttpServletRequest request) {

		UserInfo loginInfo = userInfoUtil.getLoginInfo(UserInfo.class, redisUtil, request);
		if (loginInfo == null) {
			return ResultUtil.data(ResultCode.NOT_LOGIN.getCode(), ResultCode.NOT_LOGIN.getMes(), null);
		}

		Page<ArchivesIdentRecord> page = new Page<>(pageNum == null ? 0 : pageNum, pageSize == null ? 10 : pageSize);
		QueryWrapper<ArchivesIdentRecord> queryWrapper = new QueryWrapper<>();
		if (!StringUtils.isEmpty(title)) {
			queryWrapper.like("title", "%" + title + "%");
		}
		/*
		 * identType="划控"; if(!StringUtils.isEmpty(identType)) {
		 * queryWrapper.eq("identType", identType); }
		 */
		if (!StringUtils.isEmpty(fondsId)) {
			if("admin".equals(loginInfo.getUsername()) || "超级管理员".equals(loginInfo.getRole())){

			}else {
				queryWrapper.eq("fondsId", fondsId);
			}
		}
		if (!StringUtils.isEmpty(typeId)) {
			queryWrapper.eq("typeId", typeId);
		}
		if (!StringUtils.isEmpty(classId)) {
			queryWrapper.eq("classId", classId);
		}
		if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
			queryWrapper.between("createTime", startTime, endTime);
			// queryWrapper.lt("createTime", endTime);
		}
		queryWrapper.eq("identType", identType);
//		queryWrapper.eq("state", "1");
		queryWrapper.orderByDesc("createTime");
		IPage<ArchivesIdentRecord> info = archivesIdentRecordMapper.selectPage(page, queryWrapper);
		PageInfo<ArchivesIdentRecord> data = PageUtil.data(info.getPages(), info.getCurrent(), info.getTotal(),
				info.getRecords());
		return ResultUtil.data(ResultCode.RESULT_SUCCESS.getCode(), "", data);
	}

}
